<script type="text/javascript" src="<?php echo RESOURCE_PATH;?>/js/jquery.validation.min.js"></script>
<header class="layout head padding-small">
    <a href="javascript:back(true);" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white">退货退款申请</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>
<form id="post_form" method="post" action="">
    <input type="hidden" name="form_submit" value="ok" />
    <!--退货退款申请S-->
    <div class="s-return radius-big bg-white padding height margin">
        <?php if(is_array($output['order_goods_list']) && !empty($output['order_goods_list'])) {?>
        <?php foreach ($output['order_goods_list'] as $val) { ?>
        <div class="margin-bottom clearfix">
            <a url="index.php?act=goods&op=goods_id=<?php echo $val['goods_id'];?>" class="float-left app_onclick"><img  src="<?php echo thumb($val, 'small'); ?>" onerror="this.src='<?php echo TEMPLATES_PATH;?>/images/touch2013/no_100_100.jpg'" width="100" height="100"></a>
            <a url="index.php?act=goods&op=goods_id=<?php echo $val['goods_id'];?>" class="goods-name margin-small-bottom text-small margin-small-left app_onclick"><?php echo $val['goods_name']; ?></a>
            <div>可退数量：<i class="salesNum text-red"><?php echo $val['goods_num']-$val['goods_returnnum']; ?></i></div>
            <span>退货数量：<input type="text" id="goods_<?php echo $val['goods_id']; ?>" name="goods_<?php echo $val['goods_id']; ?>" value="<?php echo $val['goods_num']-$val['goods_returnnum']; ?>" size="6" class="text-center return-salesNum"></span>
        </div>
            <?php }?>
        <?php }?>
        <div>订单编号：<span><?php echo $output['order']['order_sn']; ?></span></div>
        <div class="padding-small-top">订单金额：<span>&yen;<?php echo ncPriceFormat($output['order']['order_amount']); ?></span></div>
        <div class="padding-small-top">退货原因:
            <div class="border border-ef7f7e padding radius-big ">
                <?php echo reasonModel::getReasonSelect('reason','',array('class'=>'check border-none layout'));?>
                </div>
        </div class="padding-small-top">
        <div class="padding-small-top">退款金额：<span class="text-red">*最多可退 <?php echo ncPriceFormat($output['order']['order_amount']); ?> 元*</span>
            <div class="border border-ef7f7e padding radius-big "><input type="text" name="order_refund" id="order_refund" value="<?php echo $output['refund']['order_refund']>0?$output['refund']['order_refund']:$output['order']['order_amount']; ?>" class="border-none layout"></div>
        </div>
        <div class="padding-small-top">退货说明：
            <div>
                <textarea  rows="3" wrap="soft" name="reason_return" id="reason_return" class="border border-ef7f7e padding-small radius-big layout "><?php echo $output['refund']['buyer_message']; ?></textarea>
            </div>
            <span class="text-red">*退货退款只能申请一次，建议与卖家沟通后认真填写。</span>
        </div>
    </div>
    <div class=" margin "><button class="radius-big layout text-big border-none bg-red text-white padding height">提交申请</button></div>
    <!--退货退款申请E-->
</form>

<script type="text/javascript">
$(function(){
    $('#post_form').validate({
		submitHandler:function(form){
			$.post("index.php?act=member_order&op=return_add&p=app&order_id=<?php echo $output['order']['order_id']; ?>",$("form#post_form").serialize(),function(data){
               Jump(data);
            },'json');
		},
        rules : {
            order_refund : {
                required   : true,
                number   : true,
                min:0.01,
                max:<?php echo $output['order']['order_amount']; ?>
            },
            reason_sel : {
                required   : true,
                number   : true,
                min:1
            },
            reason_return : {
                required   : true
            }
        },
        messages : {
            order_refund  : {
                required  : '可退金额不能为空',
                number   : '可退金额为数字',
                min   : '最小金额 0.01',
	            max   : '可退金额 <?php echo $output['order']['order_amount']; ?>'
            },
            reason_sel :{
                required   : '原因不能为空',
                number   :'原因不能为空',
                min   : '原因不能为空'
            },
            reason_return  : {
                required   : '退货说明不能为空'
            }
        }
    });
});
</script> 